package com.njegovanobradovic.icet.metamodel.beans;

import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.annotations.Cascade;
import org.springframework.transaction.annotation.Transactional;

import com.njegovanobradovic.icet.core.beans.BaseBean;
import com.njegovanobradovic.icet.metamodel.Chat;
import com.njegovanobradovic.icet.metamodel.Message;
import com.njegovanobradovic.icet.metamodel.Room;
import com.njegovanobradovic.icet.metamodel.User;

@Entity
public class ChatBean extends BaseBean implements Chat{

	private Date date;
	private List<User> users;
	private List<Message> messages;
	private Room room;
	private boolean receivedMessage;
	
	@Basic
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	@ManyToMany(mappedBy="chats", cascade={CascadeType.ALL}, targetEntity=UserBean.class)
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	@OneToMany(mappedBy="chat", cascade = {CascadeType.ALL}, targetEntity=MessageBean.class)
	public List<Message> getMessages() {
		return messages;
	}
	public void setMessages(List<Message> messages) {
		this.messages = messages;
	}
	@OneToOne(mappedBy="chat", cascade = {CascadeType.ALL}, targetEntity=RoomBean.class)
	public Room getRoom() {
		return room;
	}
	public void setRoom(Room room) {
		this.room = room;
	}
	public boolean isReceivedMessage() {
		return receivedMessage;
	}
	public void setReceivedMessage(boolean receivedMessage) {
		this.receivedMessage = receivedMessage;
	}
	
	
}
